<?php
//银行卡管理
namespace app\adminbackstage\model;

use think\Model;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Bank extends Model{

    // 模型初始化
    protected static function init()
    {
        parent::init();
        //TODO:初始化内容
    }

    

    //银行卡信息
    public static function bankFind($page=1,$num=10,$where){
        $list = self::name('bank')
        ->where($where)
        ->limit(($page-1)*$num,$num)
        ->select();
        return $list;
   
    }
    
    //银行卡信息变更
    public static function bankEdit($id,$update){
        $in = self::update($update, ['id' => $id]);
        return $in;
    }
    
    public static function bankList($page=1,$num=10,$where){
        $list = self::name('bank')
        ->field('b.id,b.type,b.bank_name,b.bank_card,b.province,b.city,b.open_bank,b.account_holder,b.addtime,b.enable,b.relievetime,b.id_card,b.is_real,u.uid,u.phone')
        ->alias('b')
        ->leftJoin('pg_user u','u.uid = b.uid')
        ->where($where)
        ->order('b.id', 'desc')
        ->limit(($page-1)*$num,$num)
        ->select();
        return $list;
    }
    
    public static function countBank($where) {
        $list = self::name('bank')
        ->field('b.id,b.type,b.bank_name,b.bank_card,b.province,b.city,b.open_bank,b.account_holder,b.addtime,b.enable,b.relievetime,u.uid,u.phone')
        ->alias('b')
        ->leftJoin('pg_user u','u.uid = b.uid')
        ->where($where)
        ->order('b.id', 'desc')
        ->paginate();
        $count = $list->total();
        return $count;
    }
  
}
